<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>

	<!-- Import JsUnit core test library -->
    <script type="text/javascript" src="jsunit/app/jsUnitCore.js"></script>
    
    <!-- Import trialjs - JavaScript test helper library (see http://trialjs.googlecode.com/) -->
    <script type="text/javascript" src="../lib/trial.js"></script>
    
    <!-- Import jQuery -->
    <script type="text/javascript" src="../lib/jquery-1.3.1.js"></script>
    
    <!-- Import fake query source -->
    <script type="text/javascript" src="../src/fake-query.src.js"></script>

	<!-- Test scripts -->
    <script type="text/javascript">

		function test_simple_instance(){

			$$.reset();

			var i = $("html");

			assertEquals(1, $$.calls.length);
			assertEquals("$", $$.calls[0].name);
			assertEquals(1, $$.calls[0].arguments.length);
			assertEquals("html", $$.calls[0].arguments[0]);

			assertEquals(1, i.$$.calls.length);
			assertEquals("$", i.$$.calls[0].name);
			assertEquals(1, i.$$.calls[0].arguments.length);
			assertEquals("html", i.$$.calls[0].arguments[0]);
			
		}
		
		function test_simple_static(){
		
			$$.reset();
			
			var options = {};
			
			var i = $.ajax(options);
		
			assertEquals(1, $$.calls.length);
			assertEquals("ajax", $$.calls[0].name);
			assertEquals(1, $$.calls[0].arguments.length);
			assertEquals(options, $$.calls[0].arguments[0]);
		
		}
    	
    	function test_chained_instance(){
    	
    		$$.reset();
    		
    		var func = function(){};
    		
    		$(".something").find("li").each(func);
    	
    		assertEquals(3, $$.calls.length);
    	
    		assertEquals("$", $$.calls[0].name);
    		assertEquals(".something", $$.calls[0].arguments[0]);
    		
    		assertEquals("find", $$.calls[1].name);
    		assertEquals("li", $$.calls[1].arguments[0]);
    		
    		assertEquals("each", $$.calls[2].name);
    		assertEquals(func, $$.calls[2].arguments[0]);
    	
    	}
    	
    </script>
    
</head>
</html>